home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / t_os / igo / src / display.c < prev    next >
C/C++ Source or Header  |  1993-07-08  |  5KB  |  199 lines

  1. #define DEBUG 0
  2. /* 
  3.     TOWNS囲碁棋譜記録プログラム
  4.                                           1991/12/11  久保田俊也
  5.  
  6.     91/12/11  display モジュールを本体より分離 
  7.  
  8.  
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <winb.h>
  14. #include <egb.h>
  15. #include <te.h>
  16. #include <fntb.h>
  17. #include <gui.h>
  18. #include "igo.h"
  19. #include "ban19.h"
  20.  
  21. static char save_ban[BANSIZE2];
  22. static int banx1, bany1, banx2, bany2, ishi_r, ishi_2r;
  23.  
  24. char *gwork;    /* グラフイックBIOSワーク */
  25. char para[64] ;
  26.  
  27. int disp_init()
  28. {
  29.  
  30.     gwork = MMI_GetEgbPtr();
  31.  
  32.     EGB_writePage( gwork, 1 ) ;    /* ページ 1 に */
  33.     EGB_color( gwork, 0, 5 ) ;    /* 色を青(5)にして */
  34.     EGB_color( gwork, 2, 5 ) ;    /* 色を青(5)にして */
  35.     EGB_paintMode( gwork, 0x022 ); 
  36.     EGB_box( gwork, 0, 0, 640, 480 ); /* [46] 四角を描く */
  37.  
  38.     disp_goban(BANX, BANY, ISHI_R);
  39.     ban_init(19,save_ban);
  40.  
  41.     EGB_writePage( gwork, 0 ) ;    /* ページ 0 に */
  42.     EGB_setPalette( gwork, BLACK_COL, 0, 0, 0 );      /* [04]  */    
  43.  
  44.     return 0;
  45. }
  46.  
  47. int disp_goban(int x, int y, int z)
  48. {
  49. int i, j ;    
  50.  
  51.     banx1 = x;
  52.     bany1 = y;
  53.     ishi_r = z;
  54.     ishi_2r = ishi_r * 2;
  55.     banx2 = banx1 + (19+1)*ishi_2r;
  56.     bany2 = bany1 + (19+1)*ishi_2r;
  57.     
  58.     EGB_color( gwork, 0, 6 ) ;    /* 色を黄(6)にして */
  59.     EGB_color( gwork, 2, 6 ) ;    /* 色を黄(6)にして */
  60.     EGB_paintMode( gwork, 0x022 ); 
  61.     EGB_box( gwork, banx1, bany1, banx2, bany2);     /* [46] 四角を描く */
  62.  
  63.     EGB_color( gwork, 0, 1 ) ;
  64.     EGB_color( gwork, 2, 1 ) ;
  65.     for ( i = 0; i < 19; i++){
  66.         EGB_singleLine( gwork, (i+1)*ishi_2r+banx1, bany1+ishi_2r, 
  67.                                (i+1)*ishi_2r+banx1, bany2-ishi_2r) ; 
  68.         EGB_singleLine( gwork, banx1+ishi_2r, bany1+(i+1)*ishi_2r,
  69.                                banx2-ishi_2r, bany1+(i+1)*ishi_2r) ; 
  70.     }
  71.     for ( i = 0; i < 3; i++){
  72.         for ( j = 0; j < 3; j++){
  73.             WORD(para + 0) = 6*ishi_2r*i+banx1+4*ishi_2r;
  74.             WORD(para + 2) = 6*ishi_2r*j+bany1+4*ishi_2r;
  75.             WORD(para + 4) = 2;
  76.             EGB_circle( gwork, para ) ;  /* その位置に点を描く */
  77.         }
  78.     }
  79.     return 0;
  80. }
  81.  
  82. int disp_te(char ban[BANSIZE2],int ex_ban[BANSIZE2])
  83. {
  84. int i;
  85. char s[4];
  86. int stonex, stoney;
  87. static int save_ex_ban[BANSIZE2];
  88.  
  89.     MG_mosDisp( 2 ) ;        /* マウスを表示    シナイ */
  90.     EGB_paintMode( gwork, 0x022 );  /*  設定しないといけない? */
  91.  
  92.     for(stoney=1;stoney<(BANSIZE+1);stoney++){
  93.         for(stonex=1;stonex<(BANSIZE+1);stonex++){
  94.             if( ban[stonex + stoney*(BANSIZE+1)] != save_ban[stonex + stoney*(BANSIZE+1)] ||
  95.                 ex_ban[stonex + stoney*(BANSIZE+1)] != save_ex_ban[stonex + stoney*(BANSIZE+1)]){
  96.  
  97.                 switch(ban[stonex + stoney*(BANSIZE+1)]){
  98.                 case BLACK:
  99.                     EGB_color( gwork, 0, 1); 
  100.                     EGB_color( gwork, 2, BLACK_COL);
  101.                     gcircle((stonex)*ishi_2r+banx1, (stoney)*ishi_2r+bany1, 
  102.                             ishi_r);
  103.                     break; 
  104.                 case WHITE:
  105.                     EGB_color( gwork, 0, 1 ) ; 
  106.                     EGB_color( gwork, 2, WHITE_COL);
  107.                     gcircle((stonex)*ishi_2r+banx1, (stoney)*ishi_2r+bany1, 
  108.                             ishi_r);
  109.                     break; 
  110.                 case BLANK:
  111.                     EGB_color( gwork, 0, 0 ) ; 
  112.                     EGB_color( gwork, 2, 0 ) ; 
  113.                     EGB_box( gwork, 
  114.                             (stonex)*ishi_2r+banx1-ishi_r, 
  115.                             (stoney)*ishi_2r+bany1-ishi_r, 
  116.                             (stonex)*ishi_2r+banx1+ishi_r, 
  117.                             (stoney)*ishi_2r+bany1+ishi_r); 
  118.                                 /* [46] 四角を描く */
  119.                     break;
  120.                 }
  121.             
  122.                 switch(ban[stonex+stoney*(BANSIZE+1)]){
  123.                     case BLANK:
  124.                         break;
  125.                     case BLACK:
  126.                         EGB_color( gwork, 0, WHITE_COL) ; 
  127.                         EGB_color( gwork, 2, WHITE_COL) ; 
  128.                         break;
  129.                     case WHITE:
  130.                         EGB_color( gwork, 0, BLACK_COL) ; 
  131.                         EGB_color( gwork, 2, BLACK_COL) ; 
  132.                         break;
  133.                 }
  134.                 if(ban[stonex+stoney*(BANSIZE+1)] != -1){
  135.                         if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 100){
  136.                             s[0] = '0' + ex_ban[stonex+stoney*(BANSIZE+1)]/100;
  137.                             s[1] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%100)/10;
  138.                             s[2] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
  139.                             s[3] = '\0';
  140.                             gprint(s, (stonex)*ishi_2r+banx1-12,
  141.                                       (stoney)*ishi_2r+bany1+8);
  142.                         }else if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 10){
  143.                             s[0] = '0' + ex_ban[stonex+stoney*(BANSIZE+1)]/10;
  144.                             s[1] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
  145.                             s[2] = '\0';
  146.                             gprint(s, (stonex)*ishi_2r+banx1-8,
  147.                                       (stoney)*ishi_2r+bany1+8);
  148.                         }else if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 1){
  149.                             s[0] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
  150.                             s[1] = '\0';
  151.                             gprint(s, (stonex)*ishi_2r+banx1-4,
  152.                                       (stoney)*ishi_2r+bany1+8);
  153.                         }
  154.                 }
  155.             }
  156.         }
  157.     }
  158.     for(i=0;i<BANSIZE2;i++){
  159.         save_ban[i]    = ban[i];
  160.         save_ex_ban[i] = ex_ban[i];
  161.     }
  162.  
  163.     MG_mosDisp( 3 ) ;        /* マウスを表示する */
  164.  
  165.     return 0;
  166. }
  167.  
  168. int gprint( char *p, int x, int y)
  169. {
  170. int i;
  171. char dsp[70];
  172.  
  173.     WORD(dsp+0) = x;
  174.     WORD(dsp+2) = y;
  175.     for(i=0;i<64;i++){
  176.         dsp[i+6] = (char)(BYTE(p+i));
  177.         if(dsp[i+6] == (char)0 ){
  178.             break;
  179.         }
  180.     }
  181.     WORD(dsp+4) = i;
  182.     EGB_writeMode(gwork, 0);
  183.     EGB_sjisString(gwork, dsp);
  184.     return i;
  185.     
  186. }
  187.  
  188. int gcircle(int x, int y, int r)
  189. {
  190.  
  191.     WORD(para + 0) = x;
  192.     WORD(para + 2) = y;
  193.     WORD(para + 4) = r;
  194.     EGB_circle( gwork, para ) ;/* その位置に点を描く */
  195.  
  196.     return 0;
  197.     
  198. }
  199.